@extends('layouts.default') @section('main')
    <link href="{{URL::asset('/ueditor/')}}/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" charset="utf-8" src="{{URL::asset('/ueditor/')}}/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="{{URL::asset('/ueditor/')}}/umeditor.min.js"></script>
    <script type="text/javascript" src="{{URL::asset('/ueditor/')}}/lang/zh-cn/zh-cn.js"></script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a> <a href="{{url('role/index')}}"
                                                             class="tip-bottom">角色管理</a> <a href="#" class="current">新增角色</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span7">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>新增角色</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('role/insert')}}" method="post"
                                  class="form-horizontal" id="roleForm">
                                <div class="control-group">
                                    <label class="control-label">角色名称 :</label>

                                    <div class="controls">
                                        <input type="text" class="span11" name="name"
                                               placeholder="角色名称"/>
                                    </div>
                                </div>
                                @if($role->type == 'System')
                                    <div class="control-group">
                                        <label class="control-label">角色类型 :</label>

                                        <div class="controls">
                                            <label> <input type="radio" name="type" value="System"/> 系统管理员
                                            </label> <label> <input type="radio" name="type" value="Normal" checked="checked"/> 普通管理员
                                            </label>
                                        </div>
                                    </div>
                                @else
                                    <input type="hidden" name="type" value="Normal">
                                @endif
                                <div class="control-group">
                                    <label class="control-label">角色状态 :</label>

                                    <div class="controls">
                                        <label> <input type="radio" name="status" value="1" checked="checked"/> 开启
                                        </label> <label> <input type="radio" name="status" value="0"/> 禁用
                                        </label>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <input type="hidden" name="pid" value="{{$role->id}}">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">保存</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>

    <script>
//        var um = UM.getEditor('myEditors');
        $("#doSave").click(function () {
            $(this).attr('disabled','disabled');

            ajaxRequest($('#roleForm').serializeArray(), $('#roleForm').attr('action'), function (data) {
                if (data.status) {
                    window.location.href = data.forwardUrl;
                    alert(data.message);
                } else {
                    $("#doSave").removeAttr('disabled');

                    alert(data.message);
                }
            });
        });
    </script>
@stop
